<html>
<head><meta charset="utf-8"><title>design meeting 2019.10.28 · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html">design meeting 2019.10.28</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="179258087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258087">(Oct 28 2019 at 18:04)</a>:</h4>
<p>Hi <span class="user-group-mention" data-user-group-id="692">@WG-traits</span> <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="179258160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258160">(Oct 28 2019 at 18:05)</a>:</h4>
<p>Hi</p>



<a name="179258166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258166">(Oct 28 2019 at 18:05)</a>:</h4>
<p>so .. what to discuss today :)</p>



<a name="179258263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258263">(Oct 28 2019 at 18:06)</a>:</h4>
<p>Some thoughts:</p>



<a name="179258291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258291">(Oct 28 2019 at 18:06)</a>:</h4>
<p>we've been talking a lot about chalk, we could discuss a bit something in/around rustc?</p>



<a name="179258357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258357">(Oct 28 2019 at 18:07)</a>:</h4>
<p>I haven't quite gotten the stride here of preparing on Friday with some idea of what to dive into :)</p>



<a name="179258437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258437">(Oct 28 2019 at 18:08)</a>:</h4>
<p>my hope was that we can use this meeting (in general) to talk out tricky design questions</p>



<a name="179258477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258477">(Oct 28 2019 at 18:08)</a>:</h4>
<p>and not just kind of "lecture" on stuff that's semi already known -- but I guess that'll come in time</p>



<a name="179258577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258577">(Oct 28 2019 at 18:09)</a>:</h4>
<p>in any case, around rustc, the things that <em>I</em> have on my mind</p>
<ul>
<li>there is the pending universes PR that I opened up but haven't had a chance to return to, so we could talk through that a bit</li>
<li>we could talk about lazy normalization for constants -- I did some investigation there and had formed some kind of plan, though it's mildly out of cache</li>
<li>we could speculate on what it would take to support GATs :)</li>
</ul>



<a name="179258691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258691">(Oct 28 2019 at 18:10)</a>:</h4>
<ul>
<li>trait upcasting? I'm not sure what's next there but hacking right now, but maybe it's useful to talk out what <span class="user-mention" data-user-id="124069">@Alexander Regueiro</span> was doing (but I'd prefer to have given them some warning ;)</li>
</ul>



<a name="179258739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258739">(Oct 28 2019 at 18:11)</a>:</h4>
<p>it's okay, I can give updates.</p>



<a name="179258759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258759">(Oct 28 2019 at 18:11)</a>:</h4>
<p>ok, why don't we discuss upcast a bit?</p>



<a name="179258779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258779">(Oct 28 2019 at 18:11)</a>:</h4>
<p>mind doing it sooner rather than later, as I have to leave soon? sorry. if not I can just leave my notes here though...</p>



<a name="179258785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258785">(Oct 28 2019 at 18:11)</a>:</h4>
<p>now is good :)</p>



<a name="179258985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179258985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179258985">(Oct 28 2019 at 18:13)</a>:</h4>
<p>As context, <span class="user-mention" data-user-id="124069">@Alexander Regueiro</span> has been working on a PR to enable us to "upcast" from <code>&amp;dyn Foo</code> to <code>&amp;dyn Bar</code> is <code>Foo: Bar</code></p>



<a name="179259059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259059">(Oct 28 2019 at 18:14)</a>:</h4>
<p>cheers</p>



<a name="179259061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259061">(Oct 28 2019 at 18:14)</a>:</h4>
<p>yep</p>



<a name="179259064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259064">(Oct 28 2019 at 18:14)</a>:</h4>
<p>The general strategy is that we make the vtable for a trait <code>Foo</code> also embed the vtables for all of its supertraits</p>



<a name="179259079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259079">(Oct 28 2019 at 18:14)</a>:</h4>
<p>I was just rebasing all my work today BTW</p>



<a name="179259101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259101">(Oct 28 2019 at 18:14)</a>:</h4>
<p>yep, so right now the vtable is single (non-auto) trait, and looks like:<br>
D S A M_1 M_2 ...</p>



<a name="179259102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259102">(Oct 28 2019 at 18:14)</a>:</h4>
<p>We encountered some challenges in/around the codegen and decided we might as well try to land the "frontend" changes first</p>



<a name="179259108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259108">(Oct 28 2019 at 18:15)</a>:</h4>
<p>where D S A are drop, size, align info</p>



<a name="179259120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259120">(Oct 28 2019 at 18:15)</a>:</h4>
<p>and M_i are the method pointers</p>



<a name="179259128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259128">(Oct 28 2019 at 18:15)</a>:</h4>
<blockquote>
<p>yep, so right now the vtable is single (non-auto) trait, and looks like:<br>
D S A M_1 M_2 ...</p>
</blockquote>
<p>i.e., before your PR</p>



<a name="179259139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259139">(Oct 28 2019 at 18:15)</a>:</h4>
<p>yep</p>



<a name="179259237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259237">(Oct 28 2019 at 18:16)</a>:</h4>
<p>now (post-PR) it's D S A M_1 M_2 ... D S A N_1 N_2 ... D S A O_1 O_2 ...<br>
where N_i and O_i are pointers to the methods for supertraits</p>



<a name="179259266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259266">(Oct 28 2019 at 18:16)</a>:</h4>
<p>so the idea is we can just offset into the base vtable when upcasting</p>



<a name="179259288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259288">(Oct 28 2019 at 18:16)</a>:</h4>
<p>but yeah, we had troubles with codegen like Niko said</p>



<a name="179259315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259315">(Oct 28 2019 at 18:16)</a>:</h4>
<p>all the other parts (mainly trait &amp; MIR-related) are done.</p>



<a name="179259386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259386">(Oct 28 2019 at 18:17)</a>:</h4>
<p>so --</p>



<a name="179259394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259394">(Oct 28 2019 at 18:17)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> eddyb hasn't replied to our msgs here still, but he did actually made some changes to the relevant codegen sections of code, which I want to test to see if they helped things... who knows. he also left a new FIXME note.</p>



<a name="179259406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259406">(Oct 28 2019 at 18:17)</a>:</h4>
<p>(he pushed to your branch?)</p>



<a name="179259408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259408">(Oct 28 2019 at 18:17)</a>:</h4>
<p>if not, we'll probably want to merge it minus the codegen stuff, obviously under a feature gate, and probably with a warning</p>



<a name="179259417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259417">(Oct 28 2019 at 18:17)</a>:</h4>
<p>no, just a PR that got merged. I noticed it during my rebase today though</p>



<a name="179259545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259545">(Oct 28 2019 at 18:18)</a>:</h4>
<p>OK.</p>



<a name="179259591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259591">(Oct 28 2019 at 18:19)</a>:</h4>
<p>testing right now in fact :-)</p>



<a name="179259720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259720">(Oct 28 2019 at 18:20)</a>:</h4>
<p>We could talk a bit about what changes you wound up doing to enable this --</p>



<a name="179259783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259783">(Oct 28 2019 at 18:21)</a>:</h4>
<p>sure</p>



<a name="179259797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259797">(Oct 28 2019 at 18:21)</a>:</h4>
<p>the key thing being that when we coerce a value to a dyn type (e.g., <code>&amp;dyn Foo</code>), we generate a <code>CoerceUnsized</code> obligation that must be proven</p>



<a name="179259817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259817">(Oct 28 2019 at 18:21)</a>:</h4>
<p>(this was already true)</p>



<a name="179259911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259911">(Oct 28 2019 at 18:22)</a>:</h4>
<p>yes</p>



<a name="179259999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179259999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179259999">(Oct 28 2019 at 18:23)</a>:</h4>
<p>so sooner or later we wind up in <a href="https://github.com/rust-lang/rust/blob/8d78bf6b273848d17da8f5c92162c6a6b9b10dfd/src/librustc/traits/select.rs#L3446-L3449" target="_blank" title="https://github.com/rust-lang/rust/blob/8d78bf6b273848d17da8f5c92162c6a6b9b10dfd/src/librustc/traits/select.rs#L3446-L3449"><code>confirm_builtin_unsizing_candidate</code></a></p>



<a name="179260012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260012">(Oct 28 2019 at 18:23)</a>:</h4>
<p>and in the cast of upcasting we go in <a href="https://github.com/rust-lang/rust/blob/8d78bf6b273848d17da8f5c92162c6a6b9b10dfd/src/librustc/traits/select.rs#L3472" target="_blank" title="https://github.com/rust-lang/rust/blob/8d78bf6b273848d17da8f5c92162c6a6b9b10dfd/src/librustc/traits/select.rs#L3472">this arm</a> in particular</p>



<a name="179260128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260128">(Oct 28 2019 at 18:24)</a>:</h4>
<p>so we've basically generalized that to handle not just the case of lifetime bounds but also changing the principle traits</p>



<a name="179260156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260156">(Oct 28 2019 at 18:24)</a>:</h4>
<p>I guess, apart from that, the only other thing that really has to be changed is codegen?</p>



<a name="179260181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260181">(Oct 28 2019 at 18:25)</a>:</h4>
<p>(and there has to be some logic for computing the offsets into the vtable)</p>



<a name="179260206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260206">(Oct 28 2019 at 18:25)</a>:</h4>
<p>yep I think so</p>



<a name="179260212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260212">(Oct 28 2019 at 18:25)</a>:</h4>
<p>which I've already done</p>



<a name="179260224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260224">(Oct 28 2019 at 18:25)</a>:</h4>
<p>and I think is correct.. it's not too complex</p>



<a name="179260336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260336">(Oct 28 2019 at 18:26)</a>:</h4>
<p>ok, seems good, let me know when the PR is rebased and I will re-review I guess :)</p>



<a name="179260363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260363">(Oct 28 2019 at 18:26)</a>:</h4>
<p>Not <em>that</em> surprisingly, doesn't seem like there's a lot of unknowns to dig into here, maybe turn to another topic? not sure if anybody else has questions.</p>



<a name="179260554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260554">(Oct 28 2019 at 18:28)</a>:</h4>
<p>I'm trying to find my doc on lazy const normalization</p>



<a name="179260609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260609">(Oct 28 2019 at 18:29)</a>:</h4>
<p>I guess this was it: <a href="https://hackmd.io/S8cE-e-ORtCqjJzyOU5cLQ" target="_blank" title="https://hackmd.io/S8cE-e-ORtCqjJzyOU5cLQ">https://hackmd.io/S8cE-e-ORtCqjJzyOU5cLQ</a></p>



<a name="179260634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260634">(Oct 28 2019 at 18:29)</a>:</h4>
<p>maybe I'll talk a bit about that</p>



<a name="179260637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260637">(Oct 28 2019 at 18:29)</a>:</h4>
<p>re trait upcasts, will diamond inheritance be handled (just wondering since it wasn't mentioned, just ignore me otherwise)?</p>



<a name="179260764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260764">(Oct 28 2019 at 18:30)</a>:</h4>
<p>good question, I think it works, but we should make sure to test it -- I presume this will mean that the vtable includes two copies of "shared" ancestor methods though</p>



<a name="179260766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260766">(Oct 28 2019 at 18:30)</a>:</h4>
<p>yeah sounds fair</p>



<a name="179260777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260777">(Oct 28 2019 at 18:30)</a>:</h4>
<p>thanks for addressing that at least</p>



<a name="179260782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260782">(Oct 28 2019 at 18:30)</a>:</h4>
<p>oh yes...</p>



<a name="179260793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260793">(Oct 28 2019 at 18:30)</a>:</h4>
<p>fair point that</p>



<a name="179260828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260828">(Oct 28 2019 at 18:31)</a>:</h4>
<p>do we want to have two copies?</p>



<a name="179260830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260830">(Oct 28 2019 at 18:31)</a>:</h4>
<p>I believe it works too, as a consequence of how the <code>supertraits</code> query works, but we'll need a test!</p>



<a name="179260847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260847">(Oct 28 2019 at 18:31)</a>:</h4>
<blockquote>
<p>do we want to have two copies?</p>
</blockquote>
<p>seems ok, it's just a table of pointers</p>



<a name="179260878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260878">(Oct 28 2019 at 18:31)</a>:</h4>
<p>I guess so, it's not as bad as in C++ :)</p>



<a name="179260879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260879">(Oct 28 2019 at 18:31)</a>:</h4>
<p>there are alternative vtable layouts we could explore</p>



<a name="179260951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260951">(Oct 28 2019 at 18:32)</a>:</h4>
<p>yeah, note that the real conundrum from diamond inheritance is typically what happens to the <em>state</em></p>



<a name="179260963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179260963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179260963">(Oct 28 2019 at 18:32)</a>:</h4>
<p>and also separate compilation of method bodies</p>



<a name="179261040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261040">(Oct 28 2019 at 18:32)</a>:</h4>
<p>i.e., you want to be able to compile access to a field like <code>this-&gt;f</code>, but that requires knowing the offset of <code>f</code> -- the same is true for method calls (in the vtable), but those are read-only, so we can duplicate</p>



<a name="179261268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261268">(Oct 28 2019 at 18:34)</a>:</h4>
<p>the bigger question for me (which is orthogonal from upcasting, really) will be how we want to support things like <code>&amp;dyn (Foo + Bar)</code></p>



<a name="179261294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261294">(Oct 28 2019 at 18:35)</a>:</h4>
<blockquote>
<p>I'm trying to find my doc on lazy const normalization</p>
</blockquote>
<p>ok, circling back to this</p>



<a name="179261316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261316">(Oct 28 2019 at 18:35)</a>:</h4>
<p>it's kind of interesting, because in a way the work we've been doing on chalk is actually moving <em>away</em> from this lazy norm strategy</p>



<a name="179261426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261426">(Oct 28 2019 at 18:36)</a>:</h4>
<p>oh, I was under the impression you've been actively working on lazy norm, Niko?</p>



<a name="179261427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261427">(Oct 28 2019 at 18:36)</a>:</h4>
<p>the idea in general here is that you a constant can be an expression that needs to be evaluated</p>



<a name="179261453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261453">(Oct 28 2019 at 18:36)</a>:</h4>
<p>e.g., maybe you have <code>[u32; {1 + 2}]</code> and <code>[u32; 3]</code>, and you want to know if those are the same types</p>



<a name="179261597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261597">(Oct 28 2019 at 18:38)</a>:</h4>
<p>(sorry, got distracted look for another write-up, but I can't find it)</p>



<a name="179261605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261605">(Oct 28 2019 at 18:38)</a>:</h4>
<p>this is kind of a pain around where clauses</p>



<a name="179261656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261656">(Oct 28 2019 at 18:38)</a>:</h4>
<p>well anyway let's leave aside the root causes, the idea is that we want to do something where we wait to evaluate <code>{1+2}</code> until we are forced to do so (beacuse e.g. we are equating it with <code>3</code>)</p>



<a name="179261697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261697">(Oct 28 2019 at 18:39)</a>:</h4>
<p>this is quite related to the problem of normalizing associated types like <code>&lt;Vec&lt;u32&gt; as IntoIterator&gt;::Item</code> (which normalizes to <code>u32</code>)</p>



<a name="179261703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261703">(Oct 28 2019 at 18:39)</a>:</h4>
<p>both of them are kind of "evaluating"</p>



<a name="179261727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261727">(Oct 28 2019 at 18:39)</a>:</h4>
<p>but even though they are conceptually identical, we don't necessarily <em>have</em> to handle them in 100% the same way, though I think we would eventually like to</p>



<a name="179261741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261741">(Oct 28 2019 at 18:39)</a>:</h4>
<blockquote>
<p>oh, I was under the impression you've been actively working on lazy norm, Niko?</p>
</blockquote>
<p>I have been, under various guises</p>



<a name="179261765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261765">(Oct 28 2019 at 18:39)</a>:</h4>
<p>the thing is that I've been modifying chalk so that unification logic <em>doesn't</em> have to handle normalization</p>



<a name="179261828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261828">(Oct 28 2019 at 18:40)</a>:</h4>
<p>and instead we handle it earlier on, by translating associated types into something different</p>



<a name="179261848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261848">(Oct 28 2019 at 18:40)</a>:</h4>
<p>but in rustc we have no such translation step to fall back on</p>



<a name="179261868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261868">(Oct 28 2019 at 18:40)</a>:</h4>
<p>so the idea would be roughly that when we are equating types, if we come across two constants, we'll generate an obligation as a result that "equates" them</p>



<a name="179261890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261890">(Oct 28 2019 at 18:41)</a>:</h4>
<p>(we have the machinery to do this, in general, which we plumbed at various points for various reasons, mostly lazy norm of assoc types)</p>



<a name="179261923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261923">(Oct 28 2019 at 18:41)</a>:</h4>
<p>so if you were relating</p>
<div class="codehilite"><pre><span></span><span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="mi">1</span><span class="o">+</span><span class="mi">2</span><span class="p">}]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="mi">3</span><span class="p">]</span><span class="w"></span>
</pre></div>



<a name="179261935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261935">(Oct 28 2019 at 18:41)</a>:</h4>
<p>we would wind up with a result that is like</p>
<ul>
<li>Yes, if <code>ConstEquate(1+2, 3)</code></li>
</ul>



<a name="179261989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179261989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179261989">(Oct 28 2019 at 18:42)</a>:</h4>
<p>here <code>{1+2}</code> is presumably, in the compiler, an "unevaluated" constant,</p>



<a name="179262020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262020">(Oct 28 2019 at 18:42)</a>:</h4>
<p>which is stored as the pair of a <code>DefId</code> (to identify the MIR for <code>1+2</code> in this case) plus some substitutions</p>



<a name="179262051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262051">(Oct 28 2019 at 18:42)</a>:</h4>
<p>anyway, the <code>ConstEquate</code> obligation will get added to the fulfillment context as normal and evaluated when we are able to do so</p>



<a name="179262068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262068">(Oct 28 2019 at 18:42)</a>:</h4>
<p>there are a few complications though</p>



<a name="179262121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262121">(Oct 28 2019 at 18:43)</a>:</h4>
<p>one has to do with higher-ranked regions, and the "leak check" code we currently use to handle them</p>



<a name="179262152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262152">(Oct 28 2019 at 18:44)</a>:</h4>
<p>the other has to do with type inference variables</p>



<a name="179262200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262200">(Oct 28 2019 at 18:44)</a>:</h4>
<p>(make sense so far?)</p>



<a name="179262284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262284">(Oct 28 2019 at 18:45)</a>:</h4>
<p>I don't know if it would be helpful for this discussion, but I'm trying to remember why lazy norm was so important for const eval in the first place :)</p>



<a name="179262296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262296">(Oct 28 2019 at 18:45)</a>:</h4>
<p>heh, that was the thing I skipped over</p>



<a name="179262306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262306">(Oct 28 2019 at 18:45)</a>:</h4>
<p>let me see if I can reconstruct the example</p>



<a name="179262323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262323">(Oct 28 2019 at 18:45)</a>:</h4>
<p>I'm annoyed I didn't put notes on it in the doc</p>



<a name="179262329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262329">(Oct 28 2019 at 18:45)</a>:</h4>
<p>because it took me some time to get it back in cache</p>



<a name="179262389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262389">(Oct 28 2019 at 18:46)</a>:</h4>
<p>it's ok if you need to skip for now</p>



<a name="179262464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262464">(Oct 28 2019 at 18:47)</a>:</h4>
<p>ok I think I found it</p>



<a name="179262472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262472">(Oct 28 2019 at 18:47)</a>:</h4>
<p>from some notes of mine</p>
<blockquote>
<p>it's basically this: to evaluate {foo}, you must type-check it; to type-check it, you need its environment; so if {foo} appears in a where-clause, and the other where-clauses are ins cope, etc etc?</p>
</blockquote>



<a name="179262489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262489">(Oct 28 2019 at 18:47)</a>:</h4>
<p>let me expand on that ;)</p>



<a name="179262498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262498">(Oct 28 2019 at 18:47)</a>:</h4>
<p>so the question is, how do we evaluate <code>{1+2}</code>?</p>



<a name="179262514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262514">(Oct 28 2019 at 18:47)</a>:</h4>
<p>To do that, we need the MIR. To create the MIR, we need to type-check it.</p>



<a name="179262526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262526">(Oct 28 2019 at 18:47)</a>:</h4>
<p>Now imagine that we have</p>



<a name="179262587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262587">(Oct 28 2019 at 18:48)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">T</span>: <span class="nc">SomeTrait</span><span class="o">&lt;</span><span class="p">{</span><span class="mi">1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span><span class="p">}</span><span class="o">&gt;</span><span class="w"></span>
</pre></div>



<a name="179262600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262600">(Oct 28 2019 at 18:48)</a>:</h4>
<p>this is assuming <code>trait SomeTrait&lt;const C&gt;</code>, i.e., a const-generic future</p>



<a name="179262624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262624">(Oct 28 2019 at 18:48)</a>:</h4>
<p>ok so we have to type-check <code>{1+2}</code> -- but that is a mini-function body, and part of type-checking requires figuring out which where clauses are in scope</p>



<a name="179262635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262635">(Oct 28 2019 at 18:48)</a>:</h4>
<p>this is not relevant for an expression like <code>{1+2}</code></p>



<a name="179262640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262640">(Oct 28 2019 at 18:48)</a>:</h4>
<p>but you could have</p>



<a name="179262651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262651">(Oct 28 2019 at 18:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> ah, interesting. this will solve the apparent need for lazy normalisation in type alias bounds though?</p>



<a name="179262672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262672">(Oct 28 2019 at 18:49)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">T</span>: <span class="nb">Sized</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">G</span>: <span class="nc">SomeTrait</span><span class="o">&lt;</span><span class="n">T</span>::<span class="n">SIZE</span><span class="o">&gt;</span><span class="w"></span>
</pre></div>



<a name="179262693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262693">(Oct 28 2019 at 18:49)</a>:</h4>
<p>(where <code>SIZE</code> is an associated constant)</p>



<a name="179262701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262701">(Oct 28 2019 at 18:49)</a>:</h4>
<p>etc etc</p>



<a name="179262789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262789">(Oct 28 2019 at 18:50)</a>:</h4>
<p>so now the problem is: </p>
<ul>
<li>with <strong>eager</strong> normalization, we cna't get the predicates without normalizing -- i.e., evaluating those constants</li>
<li>but we can't <strong>evaluate</strong> without type-checking, and for that we need the predicates</li>
</ul>



<a name="179262797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262797">(Oct 28 2019 at 18:50)</a>:</h4>
<p>we actually have a similar problem with associated types</p>



<a name="179262821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262821">(Oct 28 2019 at 18:50)</a>:</h4>
<p>but we kind of "cheat" by normalizing with the unevaluated versions in scope</p>



<a name="179262867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262867">(Oct 28 2019 at 18:51)</a>:</h4>
<p>that is, </p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Iterator</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">X</span>: <span class="nc">Blah</span><span class="o">&lt;</span><span class="n">T</span>::<span class="n">Item</span><span class="o">&gt;</span><span class="w"></span>
</pre></div>


<p>we would normalize <code>T::Item</code> with <code>X: Blah&lt;T::Item&gt;</code> in scope</p>



<a name="179262883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262883">(Oct 28 2019 at 18:51)</a>:</h4>
<p>er, let me make that a better example</p>



<a name="179262926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262926">(Oct 28 2019 at 18:51)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Iterator</span><span class="o">&lt;</span><span class="n">Item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kt">u32</span><span class="o">&gt;&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">X</span>: <span class="nc">Blah</span><span class="o">&lt;</span><span class="n">T</span>::<span class="n">Item</span><span class="o">&gt;</span><span class="w"></span>
</pre></div>


<p>here, when we normalize <code>T::Item</code>, we would have <code>X: Blah&lt;T::Item&gt;</code> in scope, not <code>X: Blah&lt;u32&gt;</code></p>



<a name="179262989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179262989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179262989">(Oct 28 2019 at 18:52)</a>:</h4>
<p>we could conceivably do something similar around constants</p>



<a name="179263016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263016">(Oct 28 2019 at 18:52)</a>:</h4>
<blockquote>
<p>ah, interesting. this will solve the apparent need for lazy normalisation in type alias bounds though?</p>
</blockquote>
<p>not 100% sure what you're referring to here, <span class="user-mention" data-user-id="124069">@Alexander Regueiro</span></p>



<a name="179263065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263065">(Oct 28 2019 at 18:53)</a>:</h4>
<p>the issue with type alias bounds not working required lazy norm, people deemed</p>



<a name="179263124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263124">(Oct 28 2019 at 18:53)</a>:</h4>
<p>do you mean stuff like <code>type Foo&lt;X: Iterator&gt; = ...</code>?</p>



<a name="179263140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263140">(Oct 28 2019 at 18:53)</a>:</h4>
<p>yes that</p>



<a name="179263287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263287">(Oct 28 2019 at 18:54)</a>:</h4>
<p>ok ok -- well, yes, to handle that the way I would like to probably would want something like lazy norm too -- at the moment I'm just focused on constants, though. But there's definitely a relationship -- the user types <code>Foo&lt;T&gt;</code>, and it gets <em>normalized</em> to the <code>...</code></p>



<a name="179263324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263324">(Oct 28 2019 at 18:55)</a>:</h4>
<p>(but one of the things I was planning is to prototype these pathways for constants only)</p>



<a name="179263351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263351">(Oct 28 2019 at 18:55)</a>:</h4>
<blockquote>
<p>I don't know if it would be helpful for this discussion, but I'm trying to remember why lazy norm was so important for const eval in the first place :)</p>
</blockquote>
<p>did that answer your question, <span class="user-mention" data-user-id="116883">@tmandry</span> ?</p>



<a name="179263395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263395">(Oct 28 2019 at 18:55)</a>:</h4>
<blockquote>
<p>we could conceivably do something similar around constants</p>
</blockquote>
<p>what we would do here is presumably to type-check constants with an <em>unnormalized</em> set of where-clauses. This would probably get us .. somewhat far.</p>



<a name="179263442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263442">(Oct 28 2019 at 18:56)</a>:</h4>
<p>but it's not really the right answer longer term</p>



<a name="179263451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263451">(Oct 28 2019 at 18:56)</a>:</h4>
<p>(or at least type-check constants that appear in where-clauses)</p>



<a name="179263483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263483">(Oct 28 2019 at 18:56)</a>:</h4>
<blockquote>
<p>but we kind of "cheat" by normalizing with the unevaluated versions in scope</p>
</blockquote>
<p>I'm trying to find the code where this happens</p>



<a name="179263537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263537">(Oct 28 2019 at 18:57)</a>:</h4>
<p>it's <a href="https://github.com/rust-lang/rust/blob/8d78bf6b273848d17da8f5c92162c6a6b9b10dfd/src/librustc/traits/mod.rs#L839-L844" target="_blank" title="https://github.com/rust-lang/rust/blob/8d78bf6b273848d17da8f5c92162c6a6b9b10dfd/src/librustc/traits/mod.rs#L839-L844"><code>normalize_param_env_or_error</code></a></p>



<a name="179263582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263582">(Oct 28 2019 at 18:57)</a>:</h4>
<p>you can see <a href="https://github.com/rust-lang/rust/blob/8d78bf6b273848d17da8f5c92162c6a6b9b10dfd/src/librustc/traits/mod.rs#L876" target="_blank" title="https://github.com/rust-lang/rust/blob/8d78bf6b273848d17da8f5c92162c6a6b9b10dfd/src/librustc/traits/mod.rs#L876">this comment here</a></p>



<a name="179263665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263665">(Oct 28 2019 at 18:58)</a>:</h4>
<p>anyway, I guess that at least laid the groundwork on normalization :)</p>



<a name="179263684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263684">(Oct 28 2019 at 18:58)</a>:</h4>
<p>let's plan a bit for next time :)</p>



<a name="179263731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263731">(Oct 28 2019 at 18:59)</a>:</h4>
<p>I'm thinking we'll continue, in a sense, from where this left off, and talk about the universes + regions PR and -- maybe if we have time -- I'll talk a bit about my thoughts on how to handle regions more generally</p>



<a name="179263762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/design%20meeting%202019.10.28/near/179263762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/design.20meeting.202019.2E10.2E28.html#179263762">(Oct 28 2019 at 18:59)</a>:</h4>
<p>(seem good?)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>